<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
     <router-view></router-view>
    </div>
    <script src="js/vue.js"></script>
    <script src="js/vue-router.js"></script>
    <script>
        var Login = {
            template:`
                <div>
                    登录组件
                </div>
            `
        }
        var Register = {
            template:`
                <div>
                    注册组件
                </div>
            `
        }
        const router = new VueRouter({
            routes:[
                {path:'/',redirect:'/login'},
                {path:'/login',component:Login},
                {path:'/register',component:Register}
            ]
        })
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            router,
            watch:{
                '$route':function(to,from){
                    console.log(to,from)
                }
            }
        });
    </script>
</body>

</html>